package com.greenold.residing.controller;

import java.util.List;

import com.greenold.residing.domain.RoomDTO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.greenold.common.annotation.Log;
import com.greenold.common.core.controller.BaseController;
import com.greenold.common.core.domain.AjaxResult;
import com.greenold.common.enums.BusinessType;
import com.greenold.residing.domain.Room;
import com.greenold.residing.service.IRoomService;
import com.greenold.common.core.page.TableDataInfo;

/**
 * 床位房型Controller
 * 
 * @author ruoyi
 * @date 2025-10-15
 */
@RestController
@RequestMapping("/residing/room")
public class RoomController extends BaseController
{
    @Autowired
    private IRoomService roomService;

    /**
     * 查询床位房型列表
     */
    @PreAuthorize("@ss.hasPermi('residing:room:list')")
    @GetMapping("/list/{floorId}")
    public TableDataInfo list(@PathVariable("floorId") String floorId)
    {
        List<RoomDTO> list = roomService.selectRoomList(floorId);
        return getDataTable(list);
    }



    /**
     * 新增床位房型
     */
    @PreAuthorize("@ss.hasPermi('residing:room:add')")
    @Log(title = "床位房型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Room room)
    {
        return toAjax(roomService.insertRoom(room));
    }

    /**
     * 修改床位房型
     */
    @PreAuthorize("@ss.hasPermi('residing:room:edit')")
    @Log(title = "床位房型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Room room)
    {
        return toAjax(roomService.updateRoom(room));
    }

    /**
     * 删除床位房型
     */
    @PreAuthorize("@ss.hasPermi('residing:room:remove')")
    @Log(title = "床位房型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(roomService.deleteRoomByIds(ids));
    }
}
